<!-- 首页，支持店铺装修 -->
<template>
	<view v-if="template">
		

		<s-layout title="首页" navbar="custom" tabbar="/pages/index/index" :bgStyle="template.page"
			:navbarStyle="template.navigationBar" onShareAppMessage>
	
			<s-block v-for="(item, index) in template.components" :key="index" :styles="item.property.style">
				<s-block-item :type="item.id" :data="item.property" :styles="item.property.style" />
				
			</s-block>
			
			  
		</s-layout>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive,computed
	} from 'vue'; 
	  import { isEmpty } from 'lodash-es';
	import {
		onLoad,
		onShow,
		onReachBottom,
		onPageScroll,
		onTabItemTap,
		onPullDownRefresh
	} from '@dcloudio/uni-app';
	import sheep from '@/sheep';
	import $share from '@/sheep/platform/share';
	import $store from '@/sheep/store';
	import $platform from '@/sheep/platform';
	import _ from 'lodash-es';

	const sys_navBar = sheep.$platform.navbar;
	// const emits = defineEmits(['close', 'change']);
	// 隐藏原生tabBar
	uni.hideTabBar();
	
  const state = reactive({
   	
  });
	const template = computed(() => sheep.$store('app').template?.home);
	// 在此处拦截改变一下首页轮播图 此处先写死后期复活 放到启动函数里
	// (async function() {
		// console.log('原代码首页定制化数据',template)
		// let {
		// 	data
		// } = await index2Api.decorate();
		// console.log('首页导航配置化过高无法兼容',JSON.parse(data[1].value))
		// 改变首页底部数据 但是没有通过数组id获取商品数据接口
		// let {
		// 	data: datas
		// } = await index2Api.spids();
		// template.value.data[9].data.goodsIds = datas.list.map(item => item.id);
		// template.value.data[0].data.list = JSON.parse(data[0].value).map(item => {
		// 	return {
		// 		src: item.picUrl,
		// 		url: item.url,
		// 		title: item.name,
		// 		type: "image"
		// 	}
		// })
	// }())
 


	onLoad((options) => {
		// #ifdef MP
		
		// 小程序识别二维码
		if (options.scene) {
			const sceneParams = decodeURIComponent(options.scene).split('=');
      console.log("sceneParams=>",sceneParams);
			options[sceneParams[0]] = sceneParams[1];
		}
		// #endif

		// 预览模板
		if (options.templateId) {
			
			console.log(options.templateId,"ee")
			sheep.$store('app').init(options.templateId);
		}

		// 解析分享信息
		if (options.spm) {
			$share.decryptSpm(options.spm);
		}
	// console.log(template.components,'344567')
		// 进入指定页面(完整页面路径)
		if (options.page) {
			sheep.$router.go(decodeURIComponent(options.page));
		}
		
	
	});
	
  
    onShow((options) => {
		
		console.log("show22")
       // $store('app').init();
     // window.location.reload() 
	
       // 平台初始化加载(各平台provider提供不同的加载流程)
       // $platform.load();;
    });


onTabItemTap(() => {
		
		console.log(e);
	});
	// 下拉刷新
	onPullDownRefresh(() => {
		
		console.log("下来刷新")
		sheep.$store('app').init();
		setTimeout(function() {
			uni.stopPullDownRefresh();
		}, 800);
	});
 
	onPageScroll(() => {});
</script>

<style  lang="scss" scoped>
	.topaddress {
		
		/* width: 90%; */
		margin: auto;
		padding: 10rpx 20rpx ;
		display: flex;
		align-items: center;
		// height: 250rpx;
		background-color: white;
		
		
	}
	.topaddress_topImage {
		
		width: 28rpx;
		height: 30rpx;
		
	}
	.topaddress_topImage image{
		
		width: 28rpx;
		height: 30rpx;
		
	}
	
	.topaddress_mind {
		
	
	    padding:  0 8rpx;
		color:#18181A;
		font-size: 28rpx;
		font-weight: 800;
		max-width: 230rpx;
		overflow: hidden; /* 确保超出的内容会被隐藏 */
		  white-space: nowrap; /* 防止文本换行 */
		  text-overflow: ellipsis; /* 使用省略号表示被截断的文本 */
		/* line-height: 40rpx; */
			/* height: 30rpx; */
	   
	}
	.topaddress_adressbImage  {
		
	  // background-color: yellow;
	width: 133rpx;
	height: 10rpx;
	display: flex;
	align-items: center;
	
		
		
	}
	.topaddress_adressbImage image {
		
		/* margin-top: 10rpx; */
		width: 13rpx;
		height: 10rpx;
		/* background-color: green; */
	}
	.goods-list-box {
	  width: 50%;
	  box-sizing: border-box;
	
	  .left-list {
	    margin-right: 10rpx;
	    margin-bottom: 20rpx;
	  }
	
	  .right-list {
	    margin-left: 10rpx;
	    margin-bottom: 20rpx;
	  }
	}
	
	.goods-box {
	  &:nth-last-of-type(1) {
	    margin-bottom: 0 !important;
	  }
	
	  &:nth-child(2n) {
	    margin-right: 0;
	  }
	}
	
	.list-icon {
	  width: 80rpx;
	
	  .sicon-goods-card {
	    font-size: 40rpx;
	  }
	
	  .sicon-goods-list {
	    font-size: 40rpx;
	  }
	}
	
	.goods-card {
	  margin-left: 20rpx;
	}
	
	.list-filter-tabs {
	  background-color: #fff;
	}
	
	.filter-list-box {
	  padding: 28rpx 52rpx;
	
	  .filter-item {
	    font-size: 28rpx;
	    font-weight: 500;
	    color: #333333;
	    line-height: normal;
	    margin-bottom: 24rpx;
	
	    &:nth-last-child(1) {
	      margin-bottom: 0;
	    }
	  }
	
	  .filter-item-active {
	    color: var(--ui-BG-Main);
	  }
	}
	
	.tab-item {
	  height: 50px;
	  position: relative;
	  z-index: 11;
	
	  .tab-title {
	    font-size: 30rpx;
	  }
	
	  .cur-tab-title {
	    font-weight: $font-weight-bold;
	  }
	
	  .tab-line {
	    width: 60rpx;
	    height: 6rpx;
	    border-radius: 6rpx;
	    position: absolute;
	    left: 50%;
	    transform: translateX(-50%);
	    bottom: 10rpx;
	    background-color: var(--ui-BG-Main);
	    z-index: 12;
	  }
	}
</style>
